package edu.wpi.first.wpilibj.robot;

import edu.wpi.first.wpilibj.*;

public class LeftRightMotor extends Motor {
    
    Joystick joy;
    SignalInput si;
    AngleMotor check;

    public LeftRightMotor(Jaguar duper, Joystick overrideJoy, SignalInput si, Keybinds kB, AngleMotor check) {
        super(duper);
        joy = overrideJoy;
        this.si = si;
        this.check = check;
    }

    public LeftRightMotor(Jaguar duper, Joystick overrideJoy, SignalInput si, AngleMotor check) {
        this(duper, overrideJoy, si, new Keybinds(), check);
    }
    
    public void run() {
        while (true) {

            if (check.isManual){ 
                double x = joy.getX();
                if (x>.5) theJag.set(-.5);
                else if (x<-.5) theJag.set(.5);
                else theJag.set(0);
            }
            else if (si.comparedData > 0) {
                theJag.set(-.2);
            } 
            else if (si.comparedData < 0) {
                theJag.set(.2);
            } 
            else {
                theJag.set(0);
            }
        }
    }
}
